package com.ruoyi.system.controller.front;

import java.text.ParseException;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.controller.CxBase;
import com.ruoyi.system.domain.StudentInfo;
import com.ruoyi.system.domain.front.*;
import com.ruoyi.system.service.front.IStudentFrontService;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

import javax.validation.Valid;

/**
 * 案件信息Controller
 *
 * @author ruoyi
 * @date 2021-04-07
 */
@RestController
@RequestMapping("/system/front/studentfront")
public class StudentFrontController extends CxBase {
    @Autowired
    private IStudentFrontService studentFrontService;

    /**
     * 修改个人联系方式
     */
    @Transactional
    @Log(title = "个人联络方式", businessType = BusinessType.UPDATE)
    @PostMapping("/updatephone")
    public AjaxResult updatePhone(@RequestBody @Valid UpdatePhone updatePhone)
    {
        logput(updatePhone,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return toAjax(studentFrontService.updatePhone(updatePhone));
    }

    /**
     * 读取学生信息
     */
    @GetMapping("/selectuserinfo")
    public TableDataInfo selectuserinfo(StudentInfoFront studentInfoFront)
    {
        logput(studentInfoFront,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        TableDataInfo tableDataInfo = getDataTable(studentFrontService.selectuserinfo(studentInfoFront));
        logout(tableDataInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return tableDataInfo;
    }

    /**
     * 读取字典
     */
    @GetMapping("/selectdic")
    public TableDataInfo selectdic(DicData dicData)
    {
        logput(dicData,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        TableDataInfo tableDataInfo = getDataTable(studentFrontService.selectdic(dicData));
        logout(tableDataInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return tableDataInfo;
    }

    /**
     * 登录
     */
    @PostMapping("/login")
    public TableDataInfo login(@RequestBody @Valid Login login)
    {
        logput(login,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        TableDataInfo tableDataInfo = studentFrontService.loginfront(login);
        logout(tableDataInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return tableDataInfo;
    }
    /**
     * 学生信息记录
     */
    @PostMapping("/writeUser")
    public TableDataInfo writeUser(@RequestBody @Valid Login login)
    {
        logput(login,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        TableDataInfo tableDataInfo = studentFrontService.writeUser(login);
        logout(tableDataInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return tableDataInfo;
    }
    /**
     * 学生信息读取
     */
    @PostMapping("/readUser")
    public TableDataInfo readUser(@RequestBody @Valid Login login)
    {
        logput(login,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        TableDataInfo tableDataInfo = getDataTable(studentFrontService.readUser(login));
        logout(tableDataInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return tableDataInfo;
    }
    /**
     * 查询学生中奖信息
     */
    @GetMapping("/selectPrizeWinRecordFrontStudent")
    public TableDataInfo selectPrizeWinRecordFrontStudent(FrontUserInfo frontUserInfo)
    {
        logput(frontUserInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        TableDataInfo tableDataInfo = getDataTable(studentFrontService.selectPrizeWinRecordFrontStudent(frontUserInfo));
        logout(tableDataInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return tableDataInfo;
    }

}

